import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ErpUnitVO, ErpUnitForm, ErpUnitQuery } from '@/api/erp/erpUnit/types';

/**
 * 查询计量单位列表
 * @param query
 * @returns {*}
 */

export const listErpUnit = (query?: ErpUnitQuery): AxiosPromise<ErpUnitVO[]> => {
  return request({
    url: '/erp/erpUnit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询计量单位详细
 * @param id
 */
export const getErpUnit = (id: string | number): AxiosPromise<ErpUnitVO> => {
  return request({
    url: '/erp/erpUnit/' + id,
    method: 'get'
  });
};

/**
 * 新增计量单位
 * @param data
 */
export const addErpUnit = (data: ErpUnitForm) => {
  return request({
    url: '/erp/erpUnit',
    method: 'post',
    data: data
  });
};

/**
 * 修改计量单位
 * @param data
 */
export const updateErpUnit = (data: ErpUnitForm) => {
  return request({
    url: '/erp/erpUnit',
    method: 'put',
    data: data
  });
};

/**
 * 删除计量单位
 * @param id
 */
export const delErpUnit = (id: string | number | Array<string | number>) => {
  return request({
    url: '/erp/erpUnit/' + id,
    method: 'delete'
  });
};
